/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.jewelryexchange.service.impl;

import com.kmcsoft.goldshop.jewelryexchange.service.JewelryExchangeService;
import com.kmcsoft.goldshop.model.exchange.JewelryExchange;
import com.kmcsoft.goldshop.model.master.DiamondColor;
import com.kmcsoft.goldshop.model.master.DiamondGroup;
import com.kmcsoft.goldshop.model.master.PremiumJewelryType;
import com.kmcsoft.master.defaultservice.DefaultGenericService;
import java.util.Collection;

/**
 *
 * @author huyvu
 */
public class JdoJewelryService extends DefaultGenericService implements JewelryExchangeService {

    public JewelryExchange getJewelryExchangeById(Object id) {
        getPersistenceManager().getFetchPlan().addGroup("detach_JewelryExchange_All");
        getPersistenceManager().getFetchPlan().addGroup("detach_JewelryExchangeDetail_All");
        getPersistenceManager().getFetchPlan().addGroup("detach_DiamondExchangeDetail_All");
        getPersistenceManager().getFetchPlan().setMaxFetchDepth(-1);
        return getJdoTemplate().detachCopy(getJdoTemplate().getObjectById(JewelryExchange.class, id));
    }

    public Collection<PremiumJewelryType> getJewelryTypes() {
        getPersistenceManager().getFetchPlan().addGroup("detach_PremiumJewelryType_All");
        getPersistenceManager().getFetchPlan().setMaxFetchDepth(-1);
        return getJdoTemplate().detachCopyAll(getJdoTemplate().find(PremiumJewelryType.class, "group ==pGrp", "Boolean pGrp", PremiumJewelryType.GROUP_SPECIAL));
    }

    public Collection<DiamondGroup> getGroups() {
        return getJdoTemplate().detachCopyAll(getJdoTemplate().find(DiamondGroup.class));
    }

    public Collection<DiamondColor> getColors() {
        return getJdoTemplate().detachCopyAll(getJdoTemplate().find(DiamondColor.class));
    }
}
